import request from '../../router/axios'

export function GetMenu(idx) {
  return request({
    url: '/admin/menu',
    method: 'get',
    params: {
      appId: idx
    }
  })
}

export function fetchMenuTree(query) {
  return request({
    url: '/admin/menu/tree',
    method: 'get',
    params: query
  })
}

export function addObj(obj) {
  return request({
    url: '/admin/menu',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: '/admin/menu/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/admin/menu/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return request({
    url: '/admin/menu',
    method: 'put',
    data: obj
  })
}

export function getAllModule(params) { // 所有模块
  return request({
    url: '/admin/busi/auth/info',
    method: 'get',
    params
  })
}

export function getByAppId(params) { // 根据业务系统id获取菜单
  return request({
    url: '/admin/menu/appId',
    method: 'get',
    params
  })
}

export function getMenuAndMoudle() {
  return request({
    url: '/admin/menu/tree/apps',
    method: 'get'
  })
}
